import Vue from 'vue'
import Vuex from 'vuex'
import persistedstate from 'vuex-persistedstate';

Vue.use(Vuex)

export default new Vuex.Store({
    plugins: [persistedstate()],
    state: {
        historyList: [],
        isCollapse: false,
        roleMenu: [],
        usermsg: {},
        orderIsShow: false,
        listIsShow: false,
        isstate: false,
        token: "",
        addIsShow: false,
        orderItem: {}
    },
    mutations: {
        addToken(state, token) {
            state.token = token
        },
        addHistory(state, playload) { // 只接收2个参数

            state.historyList.push(playload);

        },
        changeCollapse(state) {
            state.isCollapse = !state.isCollapse
        },

        changeOrder(state) {
            state.orderIsShow = !state.orderIsShow
        },
        changeList(state) {
            state.listIsShow = !state.listIsShow
        },
        changestate(state) {
            state.isstate = !state.isstate
        },
        // 获取后端返回路由，动态渲染
        getUserRoot(state, playload) {
            state.roleMenu = playload
        },
        //获取用户信息，动态渲染
        getUsermsg(state, playload) {
            state.usermsg = playload
        },
        changeAdd(state) {
            state.addIsShow = !state.addIsShow
        },
        //点击订单详情传值
        msg(state, playload) {
            state.orderItem = playload
        },
        //浏览器刷新关闭插件
        changeOrderClose(state) {
            state.orderIsShow = false
        },



    },
    actions: {},
    modules: {}
})